package com.frankghost.le.h264rtmp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;

import com.frankghost.le.h264rtmp.pusher.LivePusher;

/**
 * Created by LX 创建时间： on 2017/11/29  23:34.
 * Email:hb_android@163.com
 * WeiXin:meiyingxiangmeiwei
 */
public class MainActivity extends AppCompatActivity {

    //    private static String URL = "rtmp://send1a.douyu.com/live/3778467rUeGhygmN?wsSecret=a31a5e967fe9f8d061487f44b32ae961&wsTime=5a1ec34f&wsSeek=off";
    private static String URL = "rtmp://112.74.178.77/myapp/mystream";
    private LivePusher livePusher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surface);
        //相机图像的预览
        livePusher = new LivePusher(this, surfaceView.getHolder(), URL);

    }

    public void start(View view) {
        Button btn = (Button) view;
        if (btn.getText().equals("开始直播")) {
            livePusher.startPush();
            btn.setText("停止直播");
        } else {
            livePusher.stopPush();
            btn.setText("开始直播");
        }
    }

    public void switchVideo(View view) {
        livePusher.switchCamera();
    }

}
